<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    
</head>
<body>
    <div id="app">
        <input type="button" @click="add" value="添加">
        <input type="button" name="" id="" value="删除" @click="remove">
    <ul>
        <li v-for="(item,index) in arr">
        {{index+1}} {{item}}
        </li>
    </ul>

    <h2 v-for="item in vegatables">
        {{item.name}}
    </h2>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>

    <script>
        var app=new Vue({
            el:"#app",
            data:{
                
              arr:["北京","上海","广州","深圳"],
              vegatables:[
                {name:"西蓝花"},
                {name:"番茄"}
              ]
            },
            methods: {
                add:function(){
                    this.vegatables.push({name:"花菜"})
                },
                remove:function(){
                    this.vegatables.shift()
                }
            }
        })
    </script>
    
</body>
</html>